﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;
using Lapas.Common.Forms;
using System.Drawing;
using System.Globalization;
using System.Reflection;
using System.ComponentModel;
using System.IO;
using System.Collections;

namespace Lapas.Common
{
    public partial class Helper
    {

        #region Loading splash-screen Form
        private static Lapas.Common.Forms.LoadingForm loading_Form;
        public static Lapas.Common.Forms.LoadingForm Loading_Form
        {
            get
            {
                if (loading_Form == null) { loading_Form = new Lapas.Common.Forms.LoadingForm(); }
                return loading_Form;
            }
            set { loading_Form = value; }
        }

        private static Dictionary<string, Lapas.Common.Forms.LoadingForm> loading_Form_Collection;

        public static Dictionary<string, Lapas.Common.Forms.LoadingForm> Loading_Form_Collection
        {
            get 
            {
                if (loading_Form_Collection == null) { loading_Form_Collection = new Dictionary<string, Lapas.Common.Forms.LoadingForm>(); }
                return loading_Form_Collection; 
            }
            set { loading_Form_Collection = value; }
        }


        //public static void Loading_Form_Begin()
        //{
        //    Loading_Form.Cursor = Cursors.WaitCursor;
        //    Loading_Form.Show();
        //}

        public static LoadingForm Loading_Form_Get(string title)
        {
            LoadingForm loadingForm = null;
            try
            {
                loadingForm = Loading_Form_Collection[title];
            }
            catch
            {
                loadingForm = null;
            }
            if (loadingForm == null)
            {
                loadingForm = new Lapas.Common.Forms.LoadingForm(title);
                Loading_Form_Collection.Add(title, loadingForm);
            }
            return loadingForm;
        }

        public static void Loading_Form_Begin(string title)
        {
            LoadingForm loadingForm = Loading_Form_Get(title);            
            loadingForm.Cursor = Cursors.WaitCursor;
            loadingForm.Show();
        }

        public static void Loading_Form_End(string title)
        {
            LoadingForm loadingForm = Loading_Form_Get(title);
            loadingForm.Cursor = Cursors.Default;
            loadingForm.Close();
            Loading_Form_Collection.Remove(title);
        }

        public static void UpdateCursorUI(Form form, bool isWaitCursor)
        {
            if (isWaitCursor) { form.Cursor = Cursors.WaitCursor; }
            else { form.Cursor = Cursors.Default; }
        }
        #endregion

        #region SplashScreen Form
        private static SplashScreenForm currentSplashScreenForm;

        public static SplashScreenForm CurrentSplashScreenForm
        {
            get
            {
                if (currentSplashScreenForm == null) { currentSplashScreenForm = new SplashScreenForm(); }
                return currentSplashScreenForm;
            }
            set { currentSplashScreenForm = value; }
        }

        public static void SplashScreen_Form_Begin()
        {
            SplashScreenForm form = CurrentSplashScreenForm;
            form.Cursor = Cursors.WaitCursor;
            form.Show();
        }
        public static void SplashScreen_Form_ChangeText(string text)
        {
            SplashScreenForm form = CurrentSplashScreenForm;
            form.SetText(text);
        }
        public static void SplashScreen_Form_End()
        {
            SplashScreenForm form = CurrentSplashScreenForm;
            form.Cursor = Cursors.Default;
            form.Close();
            form = null;
        }
        #endregion

        #region Agency SplashScreen Form
        private static AgencySplashScreenForm currentAgencySplashScreenForm;

        public static AgencySplashScreenForm CurrentAgencySplashScreenForm
        {
            get
            {
                if (currentAgencySplashScreenForm == null) { currentAgencySplashScreenForm = new AgencySplashScreenForm(); }
                return currentAgencySplashScreenForm;
            }
            set { currentAgencySplashScreenForm = value; }
        }

        public static void AgencySplashScreen_Form_Begin()
        {
            AgencySplashScreenForm form = CurrentAgencySplashScreenForm;
            form.Cursor = Cursors.WaitCursor;
            form.Show();
        }
        public static void AgencySplashScreen_Form_ChangeText(string text)
        {
            AgencySplashScreenForm form = CurrentAgencySplashScreenForm;
            form.SetText(text);
        }
        public static void AgencySplashScreen_Form_End()
        {
            AgencySplashScreenForm form = CurrentAgencySplashScreenForm;
            form.Cursor = Cursors.Default;
            form.Close();
            form = null;
        }
        #endregion

        #region SFS SplashScreen Form
        private static SfsSplashScreenForm currentSfsSplashScreenForm;

        public static SfsSplashScreenForm CurrentSfsSplashScreenForm
        {
            get
            {
                if (currentSfsSplashScreenForm == null) { currentSfsSplashScreenForm = new SfsSplashScreenForm(); }
                return currentSfsSplashScreenForm;
            }
            set { currentSfsSplashScreenForm = value; }
        }

        public static void SfsSplashScreen_Form_Begin()
        {
            SfsSplashScreenForm form = CurrentSfsSplashScreenForm;
            form.Cursor = Cursors.WaitCursor;
            form.Show();
        }
        public static void SfsSplashScreen_Form_ChangeText(string text)
        {
            SfsSplashScreenForm form = CurrentSfsSplashScreenForm;
            form.SetText(text);
        }
        public static void SfsSplashScreen_Form_End()
        {
            SfsSplashScreenForm form = CurrentSfsSplashScreenForm;
            form.Cursor = Cursors.Default;
            form.Close();
            form = null;
        }
        #endregion

   }
}
